<template>
	<view class="shopPhone">
		<view class="box">
			<view>
				<input type="number" maxlength="11" v-model="storeMsg.phone" placeholder="请填写手机号" />
			</view>
			
			<text>可填写方便联系的手机号</text>
			<view class="btn">
				<button type="primary" size="mini" @click="setShPhone()">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				storeMsg: {},
			}
		},
		onShow() {
			this.storeMsg = uni.getStorageSync('lph-storeInfo');
		},
		methods: {
			async setShPhone(){
				if(!(/^1[3456789]\d{9}$/.test(this.storeMsg.phone))) {
					uni.showToast({
						title:'手机号不正确',
						icon: 'none'
					})
					return
				}
				let a = await this.$http.setShPhone({phone: this.storeMsg.phone});	
				if(a.code == 200){
					uni.setStorageSync('lph-storeInfo',this.storeMsg);
					uni.showToast({
						title: a.message,
						icon:'none'
					});
					setTimeout(() =>{
							uni.navigateBack()
					},1000);
					return;
				};
				uni.showToast({
					title: a.message,
					icon:'none'
				})
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import 'static/css/myStore.scss';
</style>
